import java.lang.reflect.Method;

public class TodoReport {
    public TodoReport() {
        super();
    }

    public static void main(String[] args) {
//        getTodoReportForBusinessLogic();
        writeLog();
    }

    /**
     * This method iterates through all messages of java.com.jy.BusinessLogic class and fetches annotations defined on each of them.
     * After that it displays the information from annotation accordingly.
     */
    private static void getTodoReportForBusinessLogic() {
        
        Class businessLogicClass = BusinessLogic.class;
        for(Method method : businessLogicClass.getMethods()) {
            Todo todoAnnotation = (Todo)method.getAnnotation(Todo.class);
            if(todoAnnotation != null) {
                System.out.println(" Method Name : " + method.getName());
                System.out.println(" Author : " + todoAnnotation.author());
                System.out.println(" Priority : " + todoAnnotation.priority());
                System.out.println(" Status : " + todoAnnotation.status());
                System.out.println(" --------------------------- ");
            }
        }
    }

    private static void writeLog() {
        Class aClass = BusinessLogic.class;
        for (Method method : aClass.getMethods()) {
            Log log = method.getAnnotation(Log.class);
            if (log != null) {
                System.out.println(" 1:" + method.getName());
                System.out.println(" 2:" + log.message());
            }
        }
    }
}
